<?php

namespace zhtfrontend\models\datas;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%comments_score_history}}".
 *
 * @property int $id 自增id
 * @property int $type 类型 
 * @property int $object_id 目标id
 * @property double $score 评分
 * @property string $month 月份
 * @property int $created_at 创建时间
 */
class CommentsScoreHistory extends \zhtfrontend\components\bases\BaseModel
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%comments_score_history}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['type', 'object_id', 'created_at'], 'integer'],
            [['score'], 'number'],
            [['month'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('zhtfrontend', '编号'),
            'type' => Yii::t('zhtfrontend', '类型'),
            'object_id' => Yii::t('zhtfrontend', '目标id'),
            'score' => Yii::t('zhtfrontend', '评分'),
            'month' => Yii::t('zhtfrontend', '月份'),
            'created_at' => Yii::t('zhtfrontend', '创建时间'),
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],
        ]);
    }

}
